home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
PET
/
S-Super PET
/
(s)t2.d64
/
DISAS.ASM
< prev
next >
Wrap
Assembly Source File
|
2009-01-18
|
19KB
|
859 lines
nam ** disas.asm ** sp9000 82/10/25
; Byte feb 82 (start address in x register)
outch rmb 2
curadr rmb 2
wrkadr rmb 2
length rmb 1
page1 rmb 1
opcd rmb 1
postb rmb 1
byte1 rmb 1
byte2 rmb 1
indflg rmb 1
indbyt rmb 1
nxtbuf rmb 2
buffer equ *
rmb 4
rmb 1
rmb 2
rmb 2
rmb 2
rmb 1
hexb rmb 4
rmb 2
mnem rmb 5
rmb 1
oprand rmb 21
endbuf equ *
org $0
xref getchar_
xref initstd_
xref putchar_
xref crt
jsr initstd_
ldx #text
loop
ldb ,x+ ;load char in b
quif eq
pshs x
jsr putchar_;display char
puls x
endloop
stp swi
lp9 ldb #$17 ;disassemle 23 lines
lp8 lbsr disas9
decb
bne lp8
inchar pshs x
jsr getchar_
puls x
cmpb #'q ; quit if q
beq stp
cmpb #'^ ; uparrow backup $80
beq backup
cmpb #'p ; print screen
beq crtdmp
cmpb #$0d ; press <cr> to continue
beq lp9
cmpb #'f
bhi inchar ; branch if higher
cmpb #'0
blo inchar ; branch if lower
cmpb #'a
bhs itshexa
cmpb #'9
bls itshex
bra inchar
backup ldd #$ff80
leax d,x
bra inchar
itshexa addb #9
itshex andb #$0f ;get rid of ascii
lda #4
stx $0186
lp7 asl $0187
rol $0186
deca
bne lp7
ldx $0186
abx
bra inchar
crtdmp jsr crt
bra inchar
text fcc "Using monitor load in the x register the disassembly "
fcc "starting address,then press g pcr+1 <cr>."
fcc " Use hexnumber <cr> for new location, <cr> for next screen,"
fcc " p <cr> for printout, ^<cr> for backing up and q <cr> for "
fcb 0
disas9 pshs a,b,y,u
opt nolist
leau outch-endbuf,s
tfr u,s
stx curadr,u
sty outch,u
leax length,u
ldb #buffer-length
init1 clr ,x+
decb
bne init1
lda #$20
ldb #endbuf-buffer
init2 sta ,x+
decb
bne init2
ldx curadr,u
stx wrkadr,u
inc length,u
ldb ,x+
cmpb #$10
beq main1
cmpb #$11
bne main2
main1 stb page1,u
inc length,u
ldb ,x+
main2 stx wrkadr,u
stb opcd,u
cmpb #$80
bhs main3
cmpb #$40
blo main4
andb #$0f
bra main4
main3 andb #$0f
orb #$40
main4 lda #4
mul
leax mntab,pc
leax d,x
leay mnem,u
ldb #4
main5 lda ,x+
sta ,y+
decb
bne main5
leax oprand,u
stx nxtbuf,u
lda mnem,u
cmpa #'*
lbeq ilegop
lda opcd,u
cmpa #$c0
lbhs opc0
cmpa #$80
lbhs op80
cmpa #$40
bhs op00
cmpa #$30
lbhs op30
cmpa #$20
lbhs op20
cmpa #$10
bhs op10
bra op00
op00 tst page1,u
bne op01
cmpa #$4e
beq op01
cmpa #$5e
bne op02
op01 lbra ilegop
op02 anda #$f0
ldb #'a
cmpa #$40
beq op03
cmpa #$50
bne op04
ldb #'b
op03 stb mnem+3,u
bra op07
op04 cmpa #$60
bne op05
lbsr index
bra op07
op05 cmpa #$70
bne op06
lbsr extend
bra op07
op06 lbsr direct
op07 lbra finish
op10 ldb page1,u
beq op12
op11 lbra ilegop
op12 cmpa #$16
beq op13
cmpa #$17
bne op14
op13 lbra op23
op14 cmpa #$1a
beq op15
cmpa #$1c
bne op17
lda #'c
sta mnem+4,u
op15 lda #'#
lbsr putch
lbsr direct
op16 lbra finish
op17 cmpa #$1e
blo op16
inc length,u
ldb [wrkadr,u]
stb byte1,u
andb #$88
beq op18
cmpb #$88
bne op11
op18 ldb byte1,u
lsrb
lsrb
lsrb
lsrb
bsr reg
cmpa #'*
beq op11
lda #',
lbsr putch
ldb byte1,u
bsr reg
cmpa #'*
beq op11
bra op16
reg andb #$0f
leax regtab,pc
lda b,x
lbsr putch
cmpb #$05
bne reg1
lda #'c
bra reg3
reg1 cmpb #$0a
bne reg2
lda #'c
bra reg3
reg2 cmpb #$0b
bne reg4
lda #'p
reg3 lbsr putch
reg4 rts
op20 ldb page1,u
cmpb #$11
beq op21
cmpa #$20
bne op22
cmpb #$00
beq op22
op21 lbra ilegop
op22 cmpb #$10
bne op26
op23 ldb #3
leax mnem+2,u
op24 lda ,x+
sta ,x
leax -2,x
decb
bne op24
lda #'l
sta 1,x
lbsr rel16
op25 lbra finish
op26 lbsr rel8
bra op25
op30 ldb page1,u
cmpa #$3f
beq op301
cmpb #0
beq op32
lbra ilegop
op32 cmpa #$33
bhi op34
lbsr index
op33 lbra finish
op34 cmpa #$3c
beq op302
cmpa #$37
bhi op33
inc length,u
lda [wrkadr,u]
sta byte1,u
sta byte2,u
clrb
op35 lsl byte2,u
bcc op300
leax stktab,pc
lda b,x
cmpa #'s
bne op36
cmpa mnem+3,u
bne op36
lda #'u
op36 lbsr putch
cmpa #'p
beq op37
cmpa #'c
bne op38
op37 lda #'c
lbsr putch
bra op39
op38 cmpa #'d
bne op39
lda #'p
lbsr putch
bra op39
op39 lda #',
lbsr putch
op300 incb
cmpb #8
bne op35
ldx nxtbuf,u
leax -1,x
stx nxtbuf,u
bra op33
op301 cmpb #0
beq op33
addb #$21
stb mnem+3,u
bra op33
op302 lda #'#
lbsr putch
lbsr direct
lbra finish
op80 ldb page1,u
cmpa #$8d
bne op81
cmpb #$00
lbne ilegop
lda #'b
sta mnem,u
lbsr rel8
lbra finish
op81 anda #$8f
cmpa #$83
bne op83
cmpb #$00
beq op800
lda #'c
sta mnem,u
lda #'m
sta mnem+1,u
lda #'p
sta mnem+2,u
lda #'d
cmpb #$10
beq op82
lda #'u
op82 sta mnem+3,u
bra op800
op83 cmpa #$8c
bne op85
cmpb #$00
beq op800
lda #'y
cmpb #$10
beq op84
lda #'s
op84 sta mnem+3,u
bra op800
op85 cmpa #$8e
blo op86
cmpb #$11
lbeq ilegop
cmpb #$00
beq op800
lda #'y
sta mnem+2,u
bra op800
op86 cmpb #$00
lbne ilegop
op800 lda opcd,u
anda #$bf
cmpa #$87
beq op801
cmpa #$8d
beq op801
cmpa #$8f
bne op802
op801 lbra ilegop
op802 lda opcd,u
anda #$30
cmpa #$30
bne op803
lbsr extend
lbra finish
op803 cmpa #$20
bne op804
lbsr index
lbra finish
op804 cmpa #$10
bne op805
lbsr direct
lbra finish
op805 lda #'#
lbsr putch
lda opcd,u
anda #$8f
cmpa #$83
beq op806
cmpa #$8c
bhs op806
lbsr direct
lbra finish
op806 lbsr extend
lbra finish
opc0 ldb page1,u
anda #$cf
cmpa #$cb
bhi opc3
cmpa #$c3
bne opc0a
lda #'a
sta mnem,u
lda #'d
sta mnem+1,u
sta mnem+2,u
sta mnem+3,u
bra opc2
opc0a leax mnem+2,u
lda ,x
cmpa #'a
beq opc1
leax 1,x
opc1 inc ,x
opc2 cmpb #$00
beq opc8
bra ilegop
opc3 cmpa #$cd
bhi opc6
bne opc5
lda #'s
sta mnem,u
lda #'t
opc4 sta mnem+1,u
lda #'d
sta mnem+2,u
lda #$20
sta mnem+3,u
bra opc2
opc5 lda #'l
sta mnem,u
lda #'d
bra opc4
opc6 cmpb #$11
beq ilegop
lda #'u
cmpb #$00
beq opc7
lda #'s
opc7 sta mnem+2,u
opc8 lbra op800
ilegop leax mnileg,pc
leay mnem,u
ldb #4
ilop1 lda ,x+
sta ,y+
decb
bne ilop1
leax 1,y
stx nxtbuf,u
lda #1
sta length,u
lbra finish
index inc length,u
ldx wrkadr,u
ldb ,x+
stx wrkadr,u
stb indbyt,u
stb byte1,u
andb #$90
cmpb #$90
bne ind1
com indflg,u
lda #'[
lbsr putch
ind1 ldb indbyt,u
andb #$8f
cmpb #$80
blo ind5
cmpb #$83
bhi ind5
lda indbyt,u
anda #$11
cmpa #$10
beq ilegop
lda #',
lbsr putch
cmpb #$81
bhi ind3
lbsr getreg
lda #'+
lbsr putch
cmpb #$81
bne ind2
lbsr putch
ind2 lbra indend
ind3 lda #'-
lbsr putch
cmpb #$83
bne ind4
lbsr putch
ind4 lbsr getreg
lbra indend
ind5 lda #'a
cmpb #$86
beq ind6
lda #'b
cmpb #$85
beq ind6
lda #'d
cmpb #$8b
bne ind7
ind6 lbsr putch
lda #',
lbsr putch
lbsr getreg
lbra indend
ind7 cmpb #$8d
beq ind8
cmpb #$8c
bne ind10
ind8 lda indbyt,u
sta postb,u
;inc length
cmpb #$8d
beq ind9
lbsr rel8
ind8a lda #',
lbsr putch
lda #'p
lbsr putch
lda #'c
lbsr putch
lbra indend
ind9 lbsr rel16
bra ind8a
ind10 cmpb #$84
bne ind12
clra
ind11 lbsr put2h
lda #',
lbsr putch
bsr getreg
lbra indend
ind12 bitb #$80
bne ind13
tst indflg,u
bne ind18
ldb indbyt,u
andb #$1f
bitb #$10
beq ind12a
lda #'-
lbsr putch
orb #$e0
negb
ind12a tfr b,a
bra ind11
ind13 lda indbyt,u
sta postb,u
cmpb #$88
bne ind15
inc length,u
ldb [wrkadr,u]
stb byte1,u
bpl ind14
lda #'-
lbsr putch
negb
ind14 tfr b,a
bra ind11
ind15 cmpb #$89
bne ind16
inc length,u
inc length,u
ldd [wrkadr,u]
std byte1,u
lbsr put2h
tfr b,a
bra ind11
ind16 lda indbyt,u
cmpa #$9f
bne ind18
sta postb,u
bsr extend
bra indend
ind18 lbra ilegop
getreg pshs b
ldb indbyt,u
lda #'x
andb #$60
beq getr1
lda #'y
cmpb #$20
beq getr1
lda #'u
cmpb #$40
beq getr1
lda #'s
getr1 lbsr putch
puls b
rts
indend tst indflg,u
beq inden1
lda #']
lbsr putch
inden1 rts
direct inc length,u
lda #$24
bsr putch
lda [wrkadr,u]
sta byte1,u
bsr put2h
rts
extend bsr direct
inc length,u
inc wrkadr+1,u
bne ext1
inc wrkadr,u
ext1 lda [wrkadr,u]
sta byte2,u
bsr put2h
rts
rel8 inc length,u
lda #'(
bsr putch
lda [wrkadr,u]
tfr a,b
sta byte1,u
sex
addd #1
rel8a addd wrkadr,u
bsr put2h
tfr b,a
bsr put2h
lda #')
bsr putch
rts
rel16 inc length,u
inc length,u
lda #'(
bsr putch
ldd [wrkadr,u]
sta byte1,u
stb byte2,u
addd #2
bra rel8a
put2h pshs a
bsr put2hl
puls a
bsr put2hr
rts
put2hl lsra
lsra
lsra
lsra
put2hr anda #$f
adda #'0
cmpa #'9
bls putch
adda #7
putch ldx nxtbuf,u
sta ,x+
stx nxtbuf,u
rts
finish lda #$0d
bsr putch
leax buffer,u
stx nxtbuf,u
lda curadr,u
bsr put2h
lda curadr+1,u
bsr put2h
lda #$20
bsr putch
lda length,u
pshs a
lda page1,u
beq eoj1
bsr put2h
dec length,u
eoj1 leax buffer+7,u
stx nxtbuf,u
lda opcd,u
bsr put2h
dec length,u
lda postb,u
beq eoj2
bsr put2h
dec length,u
eoj2 leax hexb,u
stx nxtbuf,u
tst length,u
beq eoj4
lda byte1,u
lbsr put2h
dec length,u
beq eoj4
lda byte2,u
lbsr put2h
opt list
eoj4 leax buffer,u
ldb #$27
stb length,u
eoj5 ldb ,x+
dec length,u
cmpb #$0d
beq asciii
bsr outb
bra eoj5
asciii ldb #$20 ;use blanks to separate
bsr outb ; ascii print out from
dec length,u ; disassembly
bne asciii
leax buffer+5,u ;output ascii
bsr pack1 ;get 7x2 bytes
ldb #$0d
bsr outb
puls b
sex
addd curadr,u
std curadr,u
ldx curadr,u
leas endbuf-outch,u
puls a,b,y,u
rts
outb pshs x
jsr putchar_
puls x
rts
pack1 lda #$9
packit pshs a
ldb ,x+
bsr ascnib
cmpb #$20
beq blank
exg a,b ;save nibble in a
ldb ,x+
bsr ascnib
cmpb #$20
beq blank
lslb
lslb
lslb
lslb
lslb
rola
lslb
rola
lslb
rola
lslb
rola
exg a,b ;two nibbles in b
cmpb #$20
blo blank
cmpb #$7e
bhi blank
bra blnk
blank ldb #$20
blnk bsr outb
puls a
deca
bne packit
rts
ascnib cmpb #$46
bhi nogood
cmpb #$30
blo nogood
cmpb #$3a
blo good
cmpb #$41
blo nogood
subb #$7
good andb #$0f
rts
nogood ldb #$20
rts
regtab fcc "dxyusp**abcd****"
stktab fcc "psyxdbac"
mntab fcc "neg "
mnileg fcc "*** "
fcc "*** "
fcc "com "
fcc "lsr "
fcc "*** "
fcc "ror "
fcc "asr "
fcc "asl "
fcc "rol "
fcc "dec "
fcc "*** "
fcc "inc "
fcc "tst "
fcc "jmp "
fcc "clr "
fcc "*** "
fcc "*** "
fcc "nop "
fcc "sync"
fcc "*** "
fcc "*** "
fcc "bra "
fcc "bsr "
fcc "*** "
fcc "daa "
fcc "orcc"
fcc "*** "
fcc "andc"
fcc "sex "
fcc "exg "
fcc "tfr "
fcc "bra "
fcc "brn "
fcc "bhi "
fcc "bls "
fcc "bhs "
fcc "blo "
fcc "bne "
fcc "beq "
fcc "bvc "
fcc "bvs "
fcc "bpl "
fcc "bmi "
fcc "bge "
fcc "blt "
fcc "bgt "
fcc "ble "
fcc "leax"
fcc "leay"
fcc "leas"
fcc "leau"
fcc "pshs"
fcc "puls"
fcc "pshu"
fcc "pulu"
fcc "*** "
fcc "rts "
fcc "abx "
fcc "rti "
fcc "cwai"
fcc "mul "
fcc "*** "
fcc "swi "
fcc "suba"
fcc "cmpa"
fcc "sbca"
fcc "subd"
fcc "anda"
fcc "bita"
fcc "lda "
fcc "sta "
fcc "eora"
fcc "adca"
fcc "ora "
fcc "adda"
fcc "cmpx"
fcc "jsr "
fcc "ldx "
fcc "stx "
end